package com.sky.mapper;

import com.sky.annotation.autoFile;
import com.sky.dto.DishDTO;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.entity.DishFlavor;
import com.sky.entity.Setmeal;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishMapper {

    // 根据id查询套餐
    List<Dish> getDishBycateGoryId (Long id);

    /**
     * 根据分类id查询菜品数量
     * @param categoryId
     * @return
     */
    @Select("select count(id) from dish where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);


    @autoFile(value = OperationType.INSERT)
    // 新增菜品

    void saveDish(Dish dish);


    // 分页查询
    List<DishVO> pageQuery(DishPageQueryDTO DishPageQueryDTOish);

    @autoFile(value = OperationType.UPDATE)
    // 启用或禁用菜品
    void update(Dish dish);

    // 批量删除菜品
    @Delete("delete from dish where id = #{id}")
    void delete(long id);

    //查询菜品状态，是否能被删除
    @Select("select * from dish where id = #{id}")
    Dish getById(Long id);

    //查询回显
    DishVO queryById(Long id);

    // 根据菜品分类id查询套餐菜品
    List<Dish> getDishBycateGoryId(Dish dish);

//    // 根据分类id查询菜品
//    List<DishVO> getBycateGoryId(Long categoryId);

    //根据分类id查询菜品方法2
    @Select("select *from dish where category_id = #{categoryId} and status=#{status}")
    List<Dish> getDish(Dish dish);

    //查询菜品总览
    Integer getDishCOuntByStatus(Integer disable);





}
